<?php
class Page_Model_Pages
{

    /**
     * @param int $pageId
     * @return Page_Model_Mapper_Page
     */
    public function getPageById($pageId) {
        return Page_Model_DbTable_Page::getInstance()->findOneBy('id',$pageId);
    }

    /**
     * @param string $sysname
     * @return Page_Model_Mapper_Page
     */
    public function getPageBySysname($sysname) {
        return Page_Model_DbTable_Page::getInstance()->findOneBy('sysname',$sysname);
    }

    public function getList($userId = null)
    {
        $dql = Page_Model_DbTable_Page::getInstance()->createQuery();

        if($userId !== null)
            $dql->addWhere('user_id = ?', $userId);

        return $dql->execute();
    }
}